<html>
<head><meta charset="utf-8"><title>RustPython pep484 typechecker · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RustPython.20pep484.20typechecker.html">RustPython pep484 typechecker</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="165817184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RustPython%20pep484%20typechecker/near/165817184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Maxim Kurnikov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RustPython.20pep484.20typechecker.html#165817184">(May 16 2019 at 14:50)</a>:</h4>
<p>Hi. I want to implement pep484 type checker for Python in Rust, based on <a href="https://github.com/RustPython/RustPython" target="_blank" title="https://github.com/RustPython/RustPython">https://github.com/RustPython/RustPython</a> AST, as an experiment / learning experience. Is there anything I could reuse from rust-analyser for the implementation? </p>
<p>For example, salsa for incremental recomputation of AST (not part of rust-analyser, but I got idea for it from your issue tracker).</p>



<a name="165817596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RustPython%20pep484%20typechecker/near/165817596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RustPython.20pep484.20typechecker.html#165817596">(May 16 2019 at 14:55)</a>:</h4>
<p>I don't think you'll be able to reuse a lot of stuff.</p>
<p>You can use salsa for incrementality, but you probably don't need to be incremental.</p>
<p>There's ena crate which can be used to implement unification algorithm.</p>



<a name="165852187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/RustPython%20pep484%20typechecker/near/165852187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kevin Stenerson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/RustPython.20pep484.20typechecker.html#165852187">(May 16 2019 at 21:51)</a>:</h4>
<p><span class="user-mention" data-user-id="222044">@Maxim Kurnikov</span>:</p>
<p>I've been able to re-use quite a bit of Rust Analyzer's code in implementing a similar linter for web application projects.</p>
<p>See <a href="https://github.com/kestred/web-analyzer-wip" target="_blank" title="https://github.com/kestred/web-analyzer-wip">https://github.com/kestred/web-analyzer-wip</a>.</p>
<p>In particular, <code>rowan</code> is used to represent an AST, <code>salsa</code> has been nice because I plan LSP support, but as mentioned its probably unnecessary complexity in the general case; though if you go that path <code>ra_vfs</code> that has been broken out from Rust Analyzer is useful for loading files.   I've replicated some of the <code>ra_db</code> crate in <code>utils/analysis</code> and the <code>ra_parser</code>/<code>ra_syntax</code> crates in a more language-generic way in <code>utils/grammar</code>.    There is also <code>codegen/antlr</code> which generates a parser using the <code>utils/grammar</code> crate that products a <code>rowan</code> based AST using a ANTLR-like syntax if you find an existing <code>antlr</code> grammar for python.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>